#ifndef __SYSTEMS__OBJ__MGR__HPP__
# define __SYSTEMS__OBJ__MGR__HPP__

# include "core/object.hpp"
# include "system.hpp"

# include <boost/shared_ptr.hpp>
# include <boost/noncopyable.hpp>
# include <boost/thread/mutex.hpp>

# include <map>

/**
 * @brief Manages world 3D objects lifetime, position, etc.
 */
class object_manager_t : private boost::noncopyable, public if_system_t
{
public:

    typedef std::map<boost::uint64_t, boost::shared_ptr<object_t> > obj_map_t;

    static boost::shared_ptr<if_system_t> create(f_engine_t *engine);

    void start(); /*override*/

    boost::shared_ptr<object_t> create_object(const std::string &class_name, const vector3_t &init_pos, const quaternion_t &init_dir);
    bool delete_object(boost::shared_ptr<object_t> object);
    bool delete_object_by_id(boost::uint64_t ID);

    boost::mutex objects_sync_locker_;

    ~object_manager_t();

private:
    object_manager_t(f_engine_t *engine);

    obj_map_t objects_;

    f_engine_t *engine_;
};

#endif //__SYSTEMS__OBJ__MGR__HPP__
